package org.se.scut.hibernate.dao.model;

import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "tb_ablum")
public class Ablum extends Model{

	@Id
	@GeneratedValue(strategy =GenerationType.AUTO)
	private Integer id;
	
	@Column(name = "title")
	private String title;
	
	@Column(name = "overView")
	private String overView;
	
	@ManyToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
	@JoinTable(name = "tb_ablum_picture", joinColumns = @JoinColumn(name = "ablum_id", 
	referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "picture_id",
	referencedColumnName = "id"))
	private Set<Picture> pictures;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date createTime;
	
	@Column(name = "numOfLove")
	private int numOfLove;

	@ManyToOne()
	@JoinColumn(name = "userinfo_id")
	private UserInfo creator;
	
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getOverView() {
		return overView;
	}

	public void setOverView(String overView) {
		this.overView = overView;
	}

	public Set<Picture> getPictures() {
		return pictures;
	}

	public void setPictures(Set<Picture> pictures) {
		this.pictures = pictures;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public int getNumOfLove() {
		return numOfLove;
	}

	public void setNumOfLove(int numOfLove) {
		this.numOfLove = numOfLove;
	}

	public UserInfo getCreator() {
		return creator;
	}

	public void setCreator(UserInfo creator) {
		this.creator = creator;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
}
